package com.ruoyi.mall.ware.service.impl;

import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.function.Function;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.common.core.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.mall.ware.mapper.PurchaseDetailMapper;
import com.ruoyi.mall.ware.domain.PurchaseDetail;
import com.ruoyi.mall.ware.service.IPurchaseDetailService;

/**
 * 【请填写功能名称】Service业务层处理
 *
 * @author zhangqishu
 * @date 2022-06-14
 */
@Service
public class PurchaseDetailServiceImpl implements IPurchaseDetailService {
    @Autowired
    private PurchaseDetailMapper purchaseDetailMapper;

    /**
     * 查询【请填写功能名称】
     *
     * @param id 【请填写功能名称】主键
     * @return 【请填写功能名称】
     */
    @Override
    public PurchaseDetail selectPurchaseDetailById(Long id) {
        return purchaseDetailMapper.selectPurchaseDetailById(id);
    }

    /**
     * 查询【请填写功能名称】列表
     *
     * @param purchaseDetail 【请填写功能名称】
     * @return 【请填写功能名称】
     */
    @Override
    public List<PurchaseDetail> selectPurchaseDetailList(PurchaseDetail purchaseDetail) {

        QueryWrapper<PurchaseDetail> wrapper = new QueryWrapper<>();
        Integer status = purchaseDetail.getStatus();
        if (!("0".equals(String.valueOf(status)) || "null".equals(String.valueOf(status)))) {
            wrapper.eq("status", status);
        }
        Long wareId = purchaseDetail.getWareId();
        if (!("0".equals(String.valueOf(wareId)) || "null".equals(String.valueOf(wareId)))) {
            wrapper.eq("ware_id", wareId);
        }
        return purchaseDetailMapper.selectList(wrapper);
    }

    /**
     * 新增【请填写功能名称】
     *
     * @param purchaseDetail 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int insertPurchaseDetail(PurchaseDetail purchaseDetail) {
        return purchaseDetailMapper.insertPurchaseDetail(purchaseDetail);
    }

    /**
     * 修改【请填写功能名称】
     *
     * @param purchaseDetail 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int updatePurchaseDetail(PurchaseDetail purchaseDetail) {
        return purchaseDetailMapper.updatePurchaseDetail(purchaseDetail);
    }

    /**
     * 批量删除【请填写功能名称】
     *
     * @param ids 需要删除的【请填写功能名称】主键
     * @return 结果
     */
    @Override
    public int deletePurchaseDetailByIds(Long[] ids) {
        return purchaseDetailMapper.deletePurchaseDetailByIds(ids);
    }

    /**
     * 删除【请填写功能名称】信息
     *
     * @param id 【请填写功能名称】主键
     * @return 结果
     */
    @Override
    public int deletePurchaseDetailById(Long id) {
        return purchaseDetailMapper.deletePurchaseDetailById(id);
    }

    /**
     * 根据采购单id查询采购项信息
     *
     * @param id
     * @return
     */
    @Override
    public List<PurchaseDetail> listDetailByPurchaseId(Long id) {

        QueryWrapper<PurchaseDetail> wrapper = new QueryWrapper<>();

        wrapper.eq("purchase_id", id);

        return purchaseDetailMapper.selectList(wrapper);

    }

    @Override
    public boolean saveBatch(Collection<PurchaseDetail> entityList, int batchSize) {
        return false;
    }

    @Override
    public boolean saveOrUpdateBatch(Collection<PurchaseDetail> entityList, int batchSize) {
        return false;
    }

    @Override
    public boolean updateBatchById(Collection<PurchaseDetail> entityList, int batchSize) {
        return false;
    }

    @Override
    public boolean saveOrUpdate(PurchaseDetail entity) {
        return false;
    }

    @Override
    public PurchaseDetail getOne(Wrapper<PurchaseDetail> queryWrapper, boolean throwEx) {
        return null;
    }

    @Override
    public Map<String, Object> getMap(Wrapper<PurchaseDetail> queryWrapper) {
        return null;
    }

    @Override
    public <V> V getObj(Wrapper<PurchaseDetail> queryWrapper, Function<? super Object, V> mapper) {
        return null;
    }

    @Override
    public BaseMapper<PurchaseDetail> getBaseMapper() {
        return null;
    }
}
